Zarif, 59, has served as Rouhani's foreign minister since August 2013 and has been under constant pressure from hardliners who opposed his policy of detente with the West.
"I apologise for my inability to continue serving and for all the shortcomings during my term in office," Zarif said in the message posted on his verified Instagram account.
On Tuesday, he urged Iranian diplomats not to follow his lead as rumours spread of mass resignations. "I hope my resignation will act as a spur for the foreign ministry to regain its proper statutory role in the conduct of foreign affairs," the official IRNA news agency quoted him as saying. The prospect of Zarif's departure was swiftly welcomed by Iran's foes.
His ready smile and mastery of both the English language and social media have made him a formidable player on the diplomatic stage. "Zarif is gone. Good riddance," said Israeli Prime Minister Benjamin Netanyahu. Netanyahu was a bitter opponent of the 2015 nuclear deal Zarif negotiated with Barack Obama's administration and threw his own formidable lobbying powers into an ultimately successful campaign to persuade US President Donald Trump to abandon it last May.